
 package com.ami.vmedia;
 
 import com.ami.kvm.jviewer.Debug;
 import com.ami.kvm.jviewer.JViewer;
 import com.ami.vmedia.gui.VMPane;
 import javax.swing.JTabbedPane;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 public class DeviceDetector
   extends Thread
 {
   private static final long SLEEP_TIME = 1000L;
   private String[] cdDriveList;
   private String[] fdDriveList;
   private String[] hdDriveList;
   private boolean run;
   boolean cdStateFirstTime = JViewer.isCdServiceEnabled();
   boolean fdStateFirstTime = JViewer.isFdServiceEnabled();
   boolean hdStateFirstTime = JViewer.isHdServiceEnabled();
   
 
   public DeviceDetector()
   {
     this.cdDriveList = VMApp.getInstance().getCDDriveList();
     this.fdDriveList = VMApp.getInstance().getFDDriveList();
     this.hdDriveList = VMApp.getInstance().getHDDriveList();
     this.run = true;
     start();
   }
   
 
 
   public void run()
   {
     while (this.run) {
       if ((VMApp.getVMPane() != null) && 
         (VMApp.getVMPane().getVmDevicePane() != null)) {
         if (VMApp.getVMPane().getVmDevicePane().isShowing() == true)
         {
 
 
           if (VMApp.getVMPane().getVmDevicePane().getSelectedIndex() == 0) {
             VMApp.getVMPane().showMessageForSelectedTab(0);
             if (JViewer.isCdServiceEnabled()) {
               if (isDeviceDriveListUpdated(0)) {
                 VMApp.getVMPane().updateDeviceControlPanel(0, this.cdDriveList);
               }
               if (this.cdStateFirstTime) {
                 VMApp.getVMPane().updateDeviceControls(0, true);
                 this.cdStateFirstTime = false;
               }
             } else if ((!JViewer.isCdServiceEnabled()) && 
               (!this.cdStateFirstTime)) {
               VMApp.getVMPane().updateDeviceControls(0, false);
               this.cdStateFirstTime = true;
             }
             
           }
           else if (VMApp.getVMPane().getVmDevicePane().getSelectedIndex() == 1) {
             VMApp.getVMPane().showMessageForSelectedTab(1);
             if (JViewer.isFdServiceEnabled()) {
               if (isDeviceDriveListUpdated(1)) {
                 VMApp.getVMPane().updateDeviceControlPanel(1, this.fdDriveList);
               }
               if (this.fdStateFirstTime) {
                 VMApp.getVMPane().updateDeviceControls(1, true);
                 this.fdStateFirstTime = false;
               }
             } else if ((!JViewer.isFdServiceEnabled()) && 
               (!this.fdStateFirstTime)) {
               VMApp.getVMPane().updateDeviceControls(1, false);
               this.fdStateFirstTime = true;
             }
             
           }
           else if (VMApp.getVMPane().getVmDevicePane().getSelectedIndex() == 2) {
             VMApp.getVMPane().showMessageForSelectedTab(2);
             if (JViewer.isHdServiceEnabled()) {
               if (isDeviceDriveListUpdated(2)) {
                 VMApp.getVMPane().updateDeviceControlPanel(2, this.hdDriveList);
               }
               if (this.hdStateFirstTime) {
                 VMApp.getVMPane().updateDeviceControls(2, true);
                 this.hdStateFirstTime = false;
               }
             } else if ((!JViewer.isHdServiceEnabled()) && 
               (!this.hdStateFirstTime)) {
               VMApp.getVMPane().updateDeviceControls(2, false);
               this.hdStateFirstTime = true;
             }
           }
         }
         try
         {
           Thread.sleep(1000L);
         } catch (InterruptedException localInterruptedException) {
           Debug.out.println(localInterruptedException);
         }
       }
     }
   }
   
 
 
 
 
 
 
 
 
 
   public boolean isDeviceDriveListUpdated(int paramInt)
   {
     boolean bool = false;
     String[] arrayOfString1 = null;
     String[] arrayOfString2 = null;
     switch (paramInt) {
     case 0: 
       arrayOfString2 = this.cdDriveList;
       break;
     case 1: 
       arrayOfString2 = this.fdDriveList;
       break;
     case 2: 
       arrayOfString2 = this.hdDriveList;
     }
     
     
     arrayOfString1 = VMApp.getInstance().getDeviceDriveList(paramInt);
     if ((arrayOfString2 != null) || (arrayOfString1 != null))
     {
       try
       {
         if (arrayOfString1.length == arrayOfString2.length) {
           for (int i = 0; i < arrayOfString2.length; i++)
           {
             if (!arrayOfString2[i].equals(arrayOfString1[i])) {
               bool = true;
               updateDeviceDriveList(paramInt, arrayOfString1);
               break;
             }
           }
         }
         else
         {
           bool = true;
           updateDeviceDriveList(paramInt, arrayOfString1);
         }
       } catch (ArrayIndexOutOfBoundsException localArrayIndexOutOfBoundsException) {
         bool = true;
         updateDeviceDriveList(paramInt, arrayOfString1);
       } catch (NullPointerException localNullPointerException) {
         bool = true;
         updateDeviceDriveList(paramInt, arrayOfString1);
       }
     }
     return bool;
   }
   
 
 
 
 
 
 
 
   private void updateDeviceDriveList(int paramInt, String[] paramArrayOfString)
   {
     switch (paramInt) {
     case 0: 
       this.cdDriveList = paramArrayOfString;
       break;
     case 1: 
       this.fdDriveList = paramArrayOfString;
       break;
     case 2: 
       this.hdDriveList = paramArrayOfString;
     }
     
   }
   
 
 
   public void stopDeviceDetector()
   {
     this.run = false;
   }
 }


/* Location:              D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\vmedia\DeviceDetector.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */